home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / COLORDLG.PAK / USECDLL2.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  107 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1995 by Borland International, All Rights Reserved
  4. //----------------------------------------------------------------------------
  5. #include <owl/pch.h>
  6. #include <windows.h>
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include "cctltest.h"
  10.  
  11. extern "C" BOOL FAR PASCAL
  12. GetColor(HWND parentHandle, COLORREF& colorBuffer);
  13.  
  14. char appName[] = "DLL Test (non-OWL app)";
  15.  
  16. //
  17. //
  18. //
  19. LRESULT
  20. doProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  21. {
  22.   switch (message) {
  23.     case WM_DESTROY:
  24.       PostQuitMessage(0);
  25.       break;
  26.  
  27.     case WM_COMMAND:
  28.       if (LOWORD(lParam) == 0 && wParam == CM_COLOR) {
  29.         COLORREF color = RGB(0x00, 0x00, 0x00);
  30.         char msgStr[128];
  31.         if (GetColor(hWnd, color)) {
  32.           sprintf(msgStr,
  33.            "RGB intensities:\r\n\r\n Red: %d\r\n Green: %d\r\n Blue: %d",
  34.             GetRValue(color), GetGValue(color), GetBValue(color));
  35.         }
  36.         else
  37.           strcpy(msgStr, "Cancelled");
  38.         MessageBox(hWnd, msgStr, appName, MB_OK);
  39.       }
  40.       else
  41.         return DefWindowProc(hWnd, message, wParam, lParam);
  42.       break;
  43.  
  44.     default:
  45.       return DefWindowProc(hWnd, message, wParam, lParam);
  46.   }
  47.   return 0;
  48. }
  49.  
  50.  
  51. //
  52. //
  53. //
  54. #if defined(BI_PLAT_WIN32)
  55. LRESULT
  56. FAR PASCAL _stdcall
  57. WndProc(HWND h, UINT msg, WPARAM wParam, LPARAM lParam)
  58. {
  59.   return doProc(h, msg, wParam, lParam);
  60. }
  61.  
  62. #else
  63. LRESULT
  64. FAR PASCAL __export
  65. WndProc(HWND h, UINT msg, WPARAM wParam, LPARAM lParam)
  66. {
  67.   return doProc(h, msg, wParam, lParam);
  68. }
  69. #endif
  70.  
  71. //
  72. //
  73. //
  74. int PASCAL
  75. WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, int cmdShow)
  76. {
  77.   if (!hPrevInstance) {
  78.     WNDCLASS wndClass;
  79.     wndClass.style         = CS_HREDRAW | CS_VREDRAW;
  80.     wndClass.lpfnWndProc   = WndProc;
  81.     wndClass.cbClsExtra    = 0;
  82.     wndClass.cbWndExtra    = 0;
  83.     wndClass.hInstance     = hInstance;
  84.     wndClass.hIcon         = LoadIcon(0, IDI_APPLICATION);
  85.     wndClass.hCursor       = LoadCursor(0, IDC_ARROW);
  86.     wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  87.     wndClass.lpszMenuName  = MAKEINTRESOURCE(IDM_APPMENU);
  88.     wndClass.lpszClassName = appName;
  89.  
  90.     if (!RegisterClass(&wndClass))
  91.       return FALSE;
  92.   }
  93.  
  94.   HWND hWnd = CreateWindow(appName, appName, WS_OVERLAPPEDWINDOW,
  95.     CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInstance, 0);
  96.  
  97.   ShowWindow(hWnd, cmdShow);
  98.  
  99.   MSG msg;
  100.   while (GetMessage(&msg, 0, 0, 0)) {
  101.     TranslateMessage(&msg);
  102.     DispatchMessage(&msg);
  103.   }
  104.  
  105.   return msg.wParam;
  106. }
  107.